package logic

import (
	"context"
	"doctor-system/models/mysql"
	"fmt"

	"doctor-system/doctorrpc/doctorrpc"
	"doctor-system/doctorrpc/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type DelDoctorLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewDelDoctorLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DelDoctorLogic {
	return &DelDoctorLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *DelDoctorLogic) DelDoctor(in *doctorrpc.DelDoctorRequest) (*doctorrpc.DelDoctorResponse, error) {
	// todo: add your logic here and delete this line
	var doctor mysql.Doctor

	err := mysql.DB.Where("id = ?", in.Id).Delete(&doctor).Error
	if err != nil {
		return nil, fmt.Errorf("删除失败")
	}

	return &doctorrpc.DelDoctorResponse{}, nil
}
